From: Ian Campbell Date: Thu, 2 Jun 2011 16:26:10 +0000 (+0100) Subject: libxl: check return values of read/write X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~10224^2~16 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=7b7866eb2689ba6334d4beb3e1a63afa376bab90;p=xen.git libxl: check return values of read/write Some distros enable -D_FORTIFY_SOURCE=2 by default (https://wiki.ubuntu.com/CompilerFlags) which adds the warn_unused_result attribute to several functions including read(2) and write(2) Although we don't really care about error reading or writing the libxl spawn fd catch them anyway to keep this warning happy. Signed-off-by: Ian Campbell Acked-by: Ian Jackson Tested-by: Olaf Hering Committed-by: Ian Jackson --- diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index cc3ae25d1a..ba537bfde8 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -485,7 +485,9 @@ again: } if (starting && FD_ISSET(starting->for_spawn->fd, &rfds)) { unsigned char dummy; - read(starting->for_spawn->fd, &dummy, sizeof(dummy)); + if (read(starting->for_spawn->fd, &dummy, sizeof(dummy)) != 1) + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_DEBUG, + "failed to read spawn status pipe"); } } } diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c index 4a98f733a6..60d0b51014 100644 --- a/tools/libxl/libxl_exec.c +++ b/tools/libxl/libxl_exec.c @@ -220,8 +220,10 @@ int libxl__spawn_spawn(libxl__gc *gc, rc = (WIFEXITED(status) ? WEXITSTATUS(status) : WIFSIGNALED(status) && WTERMSIG(status) < 127 ? WTERMSIG(status)+128 : -1); - if (for_spawn) - write(pipes[1], &dummy, sizeof(dummy)); + if (for_spawn) { + if (write(pipes[1], &dummy, sizeof(dummy)) != 1) + perror("libxl__spawn_spawn: unable to signal child exit to parent"); + } _exit(rc); err_parent_pipes: